package com.jingdianjichi.project.application.mq;

import com.alibaba.fastjson.JSON;
import com.jingdianjichi.project.domain.bo.SubjectLikedBo;
import com.jingdianjichi.project.domain.service.SubjectLikedDomainService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * ClassName:TestConsumer
 * Package:com.jingdianjichi.project.application.mq
 * Description:
 *
 * @Author fst
 * @Create 2025/2/16 13:28
 * @Version 1.0
 */
@Component
@RocketMQMessageListener(topic = "subject-liked",consumerGroup = "subject-liked-consumer")
@Slf4j
public class SubjectLikedConsumer implements RocketMQListener<String>
{
    @Resource
    private SubjectLikedDomainService subjectLikedDomainService;
    @Override
    public void onMessage(String s)
    {
        log.info("接收到mq,内容是:{}",s);
        SubjectLikedBo subjectLikedBO = JSON.parseObject(s, SubjectLikedBo.class);
        subjectLikedDomainService.syncLikedByMessage(subjectLikedBO);
    }
}
